package com.linzm.leetcode.primary.exercises2_20230116;

/**
 * @Author zimingl
 * @Date 2023/1/17 23:12
 * @Description: 猜数字
 */
public class Demo6 {
    /**
     * 输入：guess = [1,2,3], answer = [1,2,3]
     * 输出：3
     * 解释：小A 每次都猜对了。
     * guess 的长度 = 3
     * answer 的长度 = 3
     * guess 的元素取值为 {1, 2, 3} 之一。
     * answer 的元素取值为 {1, 2, 3} 之一。
     */
    public static void main(String[] args) {
        Demo6 demo6 = new Demo6();
        int[] guess = {1,2,3}, answer = {1,2,3};
        int num = demo6.game(guess, answer);
        System.out.println(num);
    }

    private int game(int[] guess, int[] answer) {
        int count = 0;
        for (int i = 0; i < guess.length; i++) {
            if (guess[i] == answer[i]) {
                count++;
            }
        }
        return count;
    }
}
